﻿<CustomWindow:EssentialWindow x:Class="Synrc.AddressBookWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Synrc"
    xmlns:CustomWindow="clr-namespace:CustomWindow;assembly=CustomWindow"

    AllowsTransparency="True" Background="Transparent" 
    Title="Synrc Contacts" 
    Height="105"
    Width="420"
    Visibility="Collapsed"
    Loaded="Window_Loaded"
    HorizontalAlignment="Center"
    VerticalAlignment="Center"
    MouseLeftButtonDown="_OnMouseLeftButtonDown"
    LocationChanged="Window_LocationChanged"
    SizeChanged="Window_SizeChanged" 
        MinHeight="105" MinWidth="400" MaxHeight="105" 
                               ResizeMode="CanResizeWithGrip"
        Icon="/Synrc;component/Images/favicon.png" Closing="Window_Closing">

   
    <Window.Resources>

        <Style TargetType="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}">
            <Setter Property="Margin" Value="2"/>
        </Style>

        <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
        <Style.Triggers>
               <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="TextBox.IsFocused" Value="false" />
                        <Condition Property="TextBox.Text" Value="" />
                    </MultiTrigger.Conditions>
                    <Setter Property="Background">
                        <Setter.Value>
                            <VisualBrush Stretch="None" AlignmentX="Left" AlignmentY="Center">
                                <VisualBrush.Visual>
                                    <TextBlock Name="TextBlock1" Margin="2" Foreground="Gray">
                                        Search Contacts
                                    </TextBlock>
                                </VisualBrush.Visual>
                            </VisualBrush>
                        </Setter.Value>
                    </Setter>
                </MultiTrigger>
            </Style.Triggers>
        </Style>

        <Style TargetType="{x:Type Menu}" BasedOn="{StaticResource {x:Type Menu}}">
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Color="#4B90Df" Offset="0" />
                        <GradientStop Color="#295591" Offset=".5" />
                        <GradientStop Color="#183D76" Offset="0.51" />
                        <GradientStop Color="#325F9E" Offset="1" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </Style>

        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="topWhiteToBottomTransparentGradientBrush">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="White" Offset="0" />
                <GradientStop Color="Transparent" Offset="1" />
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <ControlTemplate x:Key="GlassButton" TargetType="{x:Type ToggleButton}">
            <ControlTemplate.Resources>
                <Storyboard x:Key="Timeline1">
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
                <Storyboard x:Key="Timeline2">
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="glow" Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </ControlTemplate.Resources>
            <Border BorderThickness="1,1,1,1" CornerRadius="7,2,2,7">
                <Border x:Name="border" BorderThickness="1,1,1,1" CornerRadius="7,2,2,7">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0.507*"/>
                            <RowDefinition Height="0.493*"/>
                        </Grid.RowDefinitions>
                        <Border BorderBrush="Gray" Opacity="0" HorizontalAlignment="Stretch" x:Name="glow" Width="Auto" Grid.RowSpan="2" CornerRadius="7,2,2,7">
                            <Border.Background>
                                <RadialGradientBrush>
                                    <RadialGradientBrush.RelativeTransform>
                                        <TransformGroup>
                                            <ScaleTransform ScaleX="1.702" ScaleY="2.243"/>
                                            <SkewTransform AngleX="0" AngleY="0"/>
                                            <RotateTransform Angle="0"/>
                                            <TranslateTransform X="-0.368" Y="-0.152"/>
                                        </TransformGroup>
                                    </RadialGradientBrush.RelativeTransform>
                                    <GradientStop Color="LightBlue" Offset="0"/>
                                    <GradientStop Color="LightBlue" Offset="1"/>
                                </RadialGradientBrush>
                            </Border.Background>
                        </Border>
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Width="Auto" Grid.RowSpan="2"/>
                        <Border HorizontalAlignment="Stretch" Margin="0,0,0,0" x:Name="shine" Width="Auto" CornerRadius="4,4,0,0">
                            <Border.Background>
                                <LinearGradientBrush EndPoint="0.494,0.889" StartPoint="0.494,0.028">
                                    <GradientStop Color="LightBlue" Offset="0"/>
                                    <GradientStop Color="Transparent" Offset="1"/>
                                </LinearGradientBrush>
                            </Border.Background>
                        </Border>
                    </Grid>
                </Border>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Opacity" TargetName="shine" Value="0.7"/>
                    <Setter Property="Background" TargetName="border" Value="LightBlue"/>
                    <Setter Property="Visibility" TargetName="glow" Value="Hidden"/>
                </Trigger>
                <Trigger Property="IsMouseOver" Value="True">
                    <Trigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource Timeline1}"/>
                    </Trigger.EnterActions>
                    <Trigger.ExitActions>
                        <BeginStoryboard x:Name="Timeline2_BeginStoryboard" Storyboard="{StaticResource Timeline2}"/>
                    </Trigger.ExitActions>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>


    </Window.Resources>
    <Border BorderBrush="Black" BorderThickness="1" CornerRadius="5" Background="Transparent">
        <Border BorderThickness="0" CornerRadius="5">
            <DockPanel>
                <Border Height="26" BorderThickness="0" MouseMove="Header_MouseMove" CornerRadius="5" DockPanel.Dock="Top">
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#3BB2EA" Offset="0" />
                            <GradientStop Color="#3BB2EA" Offset="0.3" />
                        </LinearGradientBrush>
                    </Border.Background>
                    <Border Name="WindowButtonsPlaceholder" HorizontalAlignment="Right" VerticalAlignment="Top"
                             Margin="0,0,10,0" />
                </Border>
                
                <!--<Thumb DragDelta="Thumb_DragDelta" 
                       HorizontalAlignment="Right"
                       DockPanel.Dock="Bottom"
                       Cursor="SizeNWSE"
                       Name="thumbResize"
                       BorderThickness="0"
                       Opacity="0"/>-->
               
                <Border BorderThickness="0" CornerRadius="5" Margin="0,-10,0,0">
                    <Border.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="#3BB2EA" Offset="0" />
                            <GradientStop Color="#EFF7FA" Offset="0.9" />
                        </LinearGradientBrush>
                    </Border.Background>
                    
    <Grid Margin="7,7,7,7">
       
		<Grid.RowDefinitions>
			<RowDefinition Height="45" />
            <RowDefinition Height="202*" />
        </Grid.RowDefinitions>
        
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="456*" />
		</Grid.ColumnDefinitions>
        <ProgressBar Name="progressBar" Maximum="0" Visibility="Collapsed" Margin="80,12,0,8" />
        <Label Margin="80,10,0,8" Name="statusLabel" VerticalContentAlignment="Center" Foreground="RoyalBlue" HorizontalContentAlignment="Center" Visibility="Hidden">Syncronizing...</Label>
        <Expander Header="Contacts" Margin="0,43,-1,0" Name="expander" HorizontalAlignment="Stretch" Grid.RowSpan="2" Collapsed="expander1_Collapsed" Expanded="expander1_Expanded" FlowDirection="RightToLeft">
            <Grid>
                <local:SearchTextBox Search="SearchTextBox_Search" Margin="-1,4,-1,0" SearchMode="Instant" Height="22" VerticalAlignment="Top" FlowDirection="LeftToRight" />
                <ListView ItemsSource="{Binding}" Style="{DynamicResource ListViewStyle}" 
                          Background="{StaticResource topWhiteToBottomTransparentGradientBrush}" BorderThickness="0" 
                          Name="ContactsView" Margin="-1,32,-1,-1" FlowDirection="LeftToRight">
                <!--SelectionChanged="ListView_SelectionChanged"> -->
                
                    <ListView.ItemContainerStyle>
                        <Style TargetType="{x:Type ListViewItem}">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                            <Setter Property="VerticalContentAlignment" Value="Center" />
                        </Style>
                    </ListView.ItemContainerStyle>
                    <ListView.View>
                        <GridView>
                            <GridView.ColumnHeaderContainerStyle>
                                <Style TargetType="{x:Type GridViewColumnHeader}">
                                    <Setter Property="Visibility" Value="Collapsed" />
                                </Style>
                            </GridView.ColumnHeaderContainerStyle>
                            <GridViewColumn Header="Name" Width="{Binding Path=ListView.Width}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="*" />
                                                <RowDefinition Height="*" />
                                                <RowDefinition Height="*" />
                                            </Grid.RowDefinitions>
                                            <Label Width="Auto" Grid.Row="0" Padding="0" Margin="0" FontSize="14" Content="{Binding Path=FullName}" />
                                            <Label Width="Auto" Grid.Row="1" Padding="0" Margin="0" Foreground="Gray" Content="{Binding Path=EMail}" />
                                            <Label Width="Auto" Grid.Row="2" Padding="0" Margin="0" Foreground="Gray" Content="{Binding Path=Phone}" />
                                        </Grid>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>
                <Label Margin="80,-22,-1,0" Name="statusMessage" FlowDirection="LeftToRight" Height="26" VerticalAlignment="Top"></Label>
            </Grid>
        </Expander>

        <local:DropDownButton 
            Content="Sync" x:Name="syncButton" Margin="0,12,0,8" HorizontalAlignment="Left" Width="74">
            
            <local:DropDownButton.DropDown>
                <ContextMenu>
                    <MenuItem Name="WindowsContacts" Header="Windows Contacts" Click="SyncWindowsContacts" />
                    <MenuItem Name="WindowsLive" Header="Windows Live" Click="SyncLiveContacts" />
                    <MenuItem Name="Outlook" Header="Microsoft Outlook" Click="SyncOutlookPIM" />
                    <MenuItem Name="Google" Header="Google" Click="SyncGMAIL" />
                </ContextMenu>
            </local:DropDownButton.DropDown>
        </local:DropDownButton>
        <StackPanel Margin="80,8,-1,8" Name="stackPanel" Orientation="Horizontal">
            <Label Name="lastSyncMessage" VerticalContentAlignment="Center" Visibility="Hidden" Height="27" Width="Auto" HorizontalContentAlignment="Left">Last Sync was made with Google</Label>
            <Label Name="url" VerticalContentAlignment="Center" Visibility="Hidden" Width="Auto" Height="26" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
               <Hyperlink Click="Hyperlink_Click" NavigateUri="http://synrc.com">Unlock!</Hyperlink>
            </Label>
        </StackPanel>
    </Grid>
                </Border>
            </DockPanel>
        </Border>
    </Border>

</CustomWindow:EssentialWindow>
